export default {
    methods:{
        i18n(name,text,key){
            return this.$ti18(name,text,"detailButtonLang.startButton",key);
        },
    },
    computed:{
        getButtons(){
            let self = this ;

            let defaultBtn = [
                {
                    id:'btnStart',
                    method:'startProcess',
                    loading:"startProcessStatus",
                    style:true,
                    name:this.i18n('startProcess','启动流程')
                },
                {
                    id:'btnSave',
                    method:'saveDraft',
                    loading:"saveDraftStatus",
                    style:false,
                    name: this.i18n('saveDraft','保存')
                },{
                    id:'flowChart',
                    method:'flowChart',
                    loading:"flowChartStatus",
                    style:false,
                    name:this.i18n('flowChart','流程图')
                },
            ]

            let btnData=defaultBtn;

            if(this.buttons.length>0){
                btnData = this.buttons.map(item=>{
                    let hasBtn = btnData.find(btn=>btn.id == item.id);
                    return hasBtn ? {...hasBtn,...item} : {...item};
                })
            }

            btnData = btnData.filter(data=>{
                return !data.hasOwnProperty('show') || data.show
            })
            let hasStyleIndex = btnData.findIndex(item=>{
                return item.style=="true" || item.style==true;
            });
            return btnData ;
        }
    }
}
